﻿class cn.eminia.AS2.Util_String {
	//[置顶]
	// import cn.eminia.AS2.Util
	// 全部不显示 Util.all0(this)
	// 全部显示 Util.all1(this)
	//
	function Util_String() {
	}
	static function splitLine(str:String) {
		var tt = str.split('\r');
		return tt;
	}
	static function delChar() {
		var aa = arguments;
		var tt = aa.shift();
		for (var i = 0; i<aa.length; i++) {
			var tt = delCharSingle(tt, aa[i]);
		}
		return tt;
	}
	static function delCharSingle(str:String, delstr:String) {
		if (str.indexOf(delstr) == -1) {
			return str;
		}
		//    
		var aa = str.split(delstr);
		var tt = '';
		for (var i = 0; i<aa.length; i++) {
			tt += aa[i];
		}
		return tt;
	}
	//******************************************************
	// [方法]
	// 将字串中固定字符b换成c
	static function replace(a:String, b:String, c:String):String {
		var j = a.split(b);
		var len = j.length;
		var a = '';
		for (var i = 0; i<len; i++) {
			a += j[i]+c;
		} 
		return rtrim(a, 1);
	}
	// 减最后一个字符
	static function rtrim(s:String, n:Number):String {
		return s.slice(0, s.length-n);
	}
	static function splitBy2Word(a:String, b:String, c:String):String {
		var i = a.indexOf(b);
		if (c == '' || c == undefined) {
			var j = a.length;
		} else {
			var j = a.indexOf(c);
		}
		return a.slice(i+b.length, j);
	}
}
